package DMSXL._2024.TX;

import java.util.Scanner;

public class jumpii {
    public static void main(String[] args) {
        int[] nums = {2,3,1,1,4};
        System.out.println(new jumpii().jump(nums));

    }
    public int jump(int[] nums) {
        if(nums.length == 1){
            return 0;
        }
        int slow = 0;
        int fast = 0;
        int count = 0;
        while (fast < nums.length - 1){
            int next = 0;
            while (slow <= fast){
                next = Math.max(slow + nums[slow],next);
                slow++;
            }
            fast = next;
            count++;
        }
        return count;
    }
}
